package com.softcits.sb01.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns="/postdemo")
public class PostDemo extends HttpServlet {

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		if(null == username || "".equals(username)) {
			System.out.println("username cannot be empty");
			resp.getWriter().write("username cannot be empty");
		}
		else {
			if(username.equals("guest") && "123456".equals(password)) {
				System.out.println("login success");
				resp.getWriter().write("login success");
			}
			else {
				System.out.println("password incorrect");
				resp.getWriter().write("password incorrect");
			}
		}
	}

}
